#include <stdio.h>

int search(int arr[], int size, int target)
{
    int left = 0;
    int right = size - 1;
    int middle = 0;
    while (left <= right)
    {
        middle = left + ((right - left) / 2);
        if (arr[middle] < target)
        {
            left = middle + 1;
        }
        else if (arr[middle] > target)
        {
            right = middle - 1;
        }
        else
        {
            return middle;
        }
    }
    return -1;
}

int main()
{
    int integer[50] = {0};
    for (int i = 0; i < 51; i++)
    {
        integer[i] = i;
    }
    int a[] = {0, 1, 2, 3, 4, 5};
    printf("%d\n", search(integer, 50, 4)); // 5
    printf("%d\n", search(integer, 50, 4)); //-1
    return 0;
}